/**
 * Copyright (c) [2022] LiuGang(libbylg@126.com)
 * TinyEditor is licensed under Mulan PSL v2.
 * You can use this software according to the terms and conditions of the Mulan PSL v2.
 * You may obtain a copy of Mulan PSL v2 at:
 *             http://license.coscl.org.cn/MulanPSL2
 * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
 * See the Mulan PSL v2 for more details.
 */
// clang-format off
//! 内存数据读写
VM_OP_DEF(VM_OP_LDB    ,    (VM_CLS_MEM | 0x00) ,   "ldb {target}, {source}, {offset}")    // 从内存读入1字节到寄存器
VM_OP_DEF(VM_OP_LDH    ,    (VM_CLS_MEM | 0x01) ,   "ldh {target}, {source}, {offset}")    // 从内存读入2字节到寄存器
VM_OP_DEF(VM_OP_LDW    ,    (VM_CLS_MEM | 0x02) ,   "ldw {target}, {source}, {offset}")    // 从内存读入4字节到寄存器
VM_OP_DEF(VM_OP_LDD    ,    (VM_CLS_MEM | 0x03) ,   "ldd {target}, {source}, {offset}")    // 从内存读入8字节到寄存器
//
VM_OP_DEF(VM_OP_STB    ,    (VM_CLS_MEM | 0x0C) ,   "stb {target}, {source}, {offset}")    // 将寄存器的1字节数据写入内存
VM_OP_DEF(VM_OP_STH    ,    (VM_CLS_MEM | 0x0D) ,   "sth {target}, {source}, {offset}")    // 将寄存器的2字节数据写入内存
VM_OP_DEF(VM_OP_STW    ,    (VM_CLS_MEM | 0x0E) ,   "stw {target}, {source}, {offset}")    // 将寄存器的4字节数据写入内存
VM_OP_DEF(VM_OP_STD    ,    (VM_CLS_MEM | 0x0F) ,   "std {target}, {source}, {offset}")    // 将寄存器的8字节数据写入内存


//! 整数算术运算
VM_OP_DEF(VM_OP_IADDI  ,    (VM_CLS_ALU | 0x00) ,   "iaddi {target} {immval}")    // 整数加
VM_OP_DEF(VM_OP_IADDR  ,    (VM_CLS_ALU | 0x01) ,   "iaddr {target} {source}")    // 整数加
VM_OP_DEF(VM_OP_ISUBI  ,    (VM_CLS_ALU | 0x02) ,   "isubi {target} {immval}")    // 整数减
VM_OP_DEF(VM_OP_ISUBR  ,    (VM_CLS_ALU | 0x03) ,   "isubr {target} {source}")    // 整数减
VM_OP_DEF(VM_OP_IMULI  ,    (VM_CLS_ALU | 0x04) ,   "imuli {target} {immval}")    // 整数乘
VM_OP_DEF(VM_OP_IMULR  ,    (VM_CLS_ALU | 0x05) ,   "imulr {target} {source}")    // 整数乘
VM_OP_DEF(VM_OP_IDIVI  ,    (VM_CLS_ALU | 0x06) ,   "idivi {target} {immval}")    // 整数除
VM_OP_DEF(VM_OP_IDIVR  ,    (VM_CLS_ALU | 0x07) ,   "idivr {target} {source}")    // 整数除
VM_OP_DEF(VM_OP_IMODI  ,    (VM_CLS_ALU | 0x08) ,   "imodi {target} {immval}")    // 整数求余
VM_OP_DEF(VM_OP_IMODR  ,    (VM_CLS_ALU | 0x09) ,   "imodr {target} {source}")    // 整数求余


//! 整数位运算
VM_OP_DEF(VM_OP_BANDI  ,    (VM_CLS_BIT | 0x00) ,   "bandi {target} {immval}")    // 整数按位与
VM_OP_DEF(VM_OP_BANDR  ,    (VM_CLS_BIT | 0x01) ,   "bandr {target} {source}")    // 整数按位与
VM_OP_DEF(VM_OP_BCORI  ,    (VM_CLS_BIT | 0x02) ,   "bcori {target} {immval}")    // 整数按位或
VM_OP_DEF(VM_OP_BCORR  ,    (VM_CLS_BIT | 0x03) ,   "bcorr {target} {source}")    // 整数按位或
VM_OP_DEF(VM_OP_BXORI  ,    (VM_CLS_BIT | 0x04) ,   "bxori {target} {immval}")    // 整数按位异或
VM_OP_DEF(VM_OP_BXORR  ,    (VM_CLS_BIT | 0x05) ,   "bxorr {target} {source}")    // 整数按位异或
VM_OP_DEF(VM_OP_BSHLI  ,    (VM_CLS_BIT | 0x06) ,   "bshli {target} {immval}")    // 整数左移
VM_OP_DEF(VM_OP_BSHLR  ,    (VM_CLS_BIT | 0x07) ,   "bshlr {target} {source}")    // 整数左移
VM_OP_DEF(VM_OP_BSHRI  ,    (VM_CLS_BIT | 0x08) ,   "bshri {target} {immval}")    // 整数右移
VM_OP_DEF(VM_OP_BSHRR  ,    (VM_CLS_BIT | 0x09) ,   "bshrr {target} {source}")    // 整数右移
VM_OP_DEF(VM_OP_BSHSI  ,    (VM_CLS_BIT | 0x0A) ,   "bshsi {target} {immval}")    // 带符号位的整数右移
VM_OP_DEF(VM_OP_BSHSR  ,    (VM_CLS_BIT | 0x0B) ,   "bshsr {target} {source}")    // 带符号位的整数右移


//! 浮点数运算
VM_OP_DEF(VM_OP_FADD   ,    (VM_CLS_FPU | 0x00) ,   "fadd {target} {source}")     // 浮点数加
VM_OP_DEF(VM_OP_FSUB   ,    (VM_CLS_FPU | 0x01) ,   "fsub {target} {source}")     // 浮点数减
VM_OP_DEF(VM_OP_FMUL   ,    (VM_CLS_FPU | 0x02) ,   "fmul {target} {source}")     // 浮点数乘
VM_OP_DEF(VM_OP_FDIV   ,    (VM_CLS_FPU | 0x03) ,   "fdiv {target} {source}")     // 浮点数乘
VM_OP_DEF(VM_OP_FMOD   ,    (VM_CLS_FPU | 0x04) ,   "fmod {target} {source}")     // 浮点数取余数
//
VM_OP_DEF(VM_OP_FEQ    ,    (VM_CLS_FPU | 0x0A) ,   "feq {target} {source}")      // 浮点数相等
VM_OP_DEF(VM_OP_FNE    ,    (VM_CLS_FPU | 0x0B) ,   "fne {target} {source}")      // 浮点数不相等
VM_OP_DEF(VM_OP_FGT    ,    (VM_CLS_FPU | 0x0C) ,   "fgt {target} {source}")      // 浮点数大于
VM_OP_DEF(VM_OP_FGE    ,    (VM_CLS_FPU | 0x0D) ,   "fge {target} {source}")      // 浮点数大于或等于
VM_OP_DEF(VM_OP_FLT    ,    (VM_CLS_FPU | 0x0E) ,   "flt {target} {source}")      // 浮点小于
VM_OP_DEF(VM_OP_FLE    ,    (VM_CLS_FPU | 0x0F) ,   "fle {target} {source}")      // 浮点数小于等于


//! 寄存器间数据交换
VM_OP_DEF(VM_OP_MOVE   ,    (VM_CLS_REX | 0x00) ,   "move {target} {source}")     //  寄存器间数据移动
VM_OP_DEF(VM_OP_COPY   ,    (VM_CLS_REX | 0x01) ,   "copy {target} {source}")     //  寄存器间数据拷贝
VM_OP_DEF(VM_OP_SWAP   ,    (VM_CLS_REX | 0x02) ,   "swap {target} {source}")     //  寄存器间数据交换
VM_OP_DEF(VM_OP_FILL   ,    (VM_CLS_REX | 0x04) ,   "fill {target} {offset} {immval}")     //  基于立即数模板填充寄存器
VM_OP_DEF(VM_OP_SETB   ,    (VM_CLS_REX | 0x05) ,   "setb {target} {immval}")     //  给寄存器设置为立即数
VM_OP_DEF(VM_OP_SETH   ,    (VM_CLS_REX | 0x06) ,   "seth {target} {immval}")     //  给寄存器设置为立即数
VM_OP_DEF(VM_OP_SETW   ,    (VM_CLS_REX | 0x07) ,   "setw {target} {immval}")     //  给寄存器设置为立即数
VM_OP_DEF(VM_OP_SETD   ,    (VM_CLS_REX | 0x08) ,   "setd {target} {immval}")     //  给寄存器设置为立即数


//! 数据转换运算
VM_OP_DEF(VM_OP_BNOT   ,    (VM_CLS_CST | 0x00) ,   "bnot {target}")     //  按位取反
VM_OP_DEF(VM_OP_INEG   ,    (VM_CLS_CST | 0x01) ,   "ineg {target}")     //  整数取负
VM_OP_DEF(VM_OP_FNEG   ,    (VM_CLS_CST | 0x02) ,   "fneg {target}")     //  浮点数取负
VM_OP_DEF(VM_OP_ITOF   ,    (VM_CLS_CST | 0x03) ,   "itof {target}")     //  整数转浮点数
VM_OP_DEF(VM_OP_FTOI   ,    (VM_CLS_CST | 0x04) ,   "ftoi {target}")     //  浮点转整数
//
VM_OP_DEF(VM_OP_SBEX   ,    (VM_CLS_CST | 0x0D) ,   "sbex {target}")     //  1字节有符号数扩展
VM_OP_DEF(VM_OP_SHEX   ,    (VM_CLS_CST | 0x0E) ,   "shex {target}")     //  2字节有符号数扩展
VM_OP_DEF(VM_OP_SWEX   ,    (VM_CLS_CST | 0x0F) ,   "swex {target}")     //  4字节有符号数扩展

//! 跳转指令
VM_OP_DEF(VM_OP_FAULT  ,    (VM_CLS_JMP | 0x00) ,   "fault {immval}")
VM_OP_DEF(VM_OP_RETURN ,    (VM_CLS_JMP | 0x01) ,   "return")
VM_OP_DEF(VM_OP_CALL   ,    (VM_CLS_JMP | 0x02) ,   "call {target} {immval}")
VM_OP_DEF(VM_OP_JEZ    ,    (VM_CLS_JMP | 0x03) ,   "jez  {target} {offset}")
VM_OP_DEF(VM_OP_JNZ    ,    (VM_CLS_JMP | 0x04) ,   "jnz  {target} {offset}")
VM_OP_DEF(VM_OP_JMP    ,    (VM_CLS_JMP | 0x05) ,   "jmp  {target} {offset}")

//! 基于整数比较的跳转指令
VM_OP_DEF(VM_OP_JEQ    ,    (VM_CLS_JBC | 0x00) ,   "jeq   {target} {source} {offset}")      // 浮点数相等
VM_OP_DEF(VM_OP_JNE    ,    (VM_CLS_JBC | 0x01) ,   "jne   {target} {source} {offset}")      // 浮点数不相等
VM_OP_DEF(VM_OP_JGT    ,    (VM_CLS_JBC | 0x02) ,   "jgt   {target} {source} {offset}")      // 浮点数大于
VM_OP_DEF(VM_OP_JGE    ,    (VM_CLS_JBC | 0x03) ,   "jge   {target} {source} {offset}")      // 浮点数大于或等于
VM_OP_DEF(VM_OP_JLT    ,    (VM_CLS_JBC | 0x04) ,   "jlt   {target} {source} {offset}")      // 浮点小于
VM_OP_DEF(VM_OP_JLE    ,    (VM_CLS_JBC | 0x05) ,   "jle   {target} {source} {offset}")      // 浮点数小于等于
VM_OP_DEF(VM_OP_JET    ,    (VM_CLS_JBC | 0x06) ,   "jet   {target} {source} {offset}")      // 浮点数小于等于
VM_OP_DEF(VM_OP_JSGT   ,    (VM_CLS_JBC | 0x07) ,   "jfgt  {target} {source} {offset}")      // 浮点数大于
VM_OP_DEF(VM_OP_JSGE   ,    (VM_CLS_JBC | 0x08) ,   "jfge  {target} {source} {offset}")      // 浮点数大于或等于
VM_OP_DEF(VM_OP_JSLT   ,    (VM_CLS_JBC | 0x09) ,   "jflt  {target} {source} {offset}")      // 浮点小于
VM_OP_DEF(VM_OP_JSLE   ,    (VM_CLS_JBC | 0x0A) ,   "jfle  {target} {source} {offset}")      // 浮点数小于等于

// clang-format on
